package com.bmicpd.gzh.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author ytree
 */
public class PatternUtils {

    /**
     * 获取正则匹配到的结果
     * @param rawData 数据源
     * @param regex 正则表达式
     * @param index 匹配结果的下标
     * @return String
     */
    public static String getMatchData(String rawData, String regex ,int index){

        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(rawData);
        String endData = null;
        while (matcher.find()){
            endData = matcher.group(index);
        }

        return endData;
    }
}
